package com.starblink.login.changeboundemail.inputemail.ui

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.starblink.android.basic.base.BaseViewModel
import com.starblink.android.basic.network.base.SkGqlClient
import com.starblink.rocketreserver.CheckEmailMutation
import kotlinx.coroutines.launch

class ChangeBoundEmailInputEmailVM : BaseViewModel() {
    val checkResultLiveData: MutableLiveData<Boolean> = MutableLiveData()

    fun checkEmail(email: String) {
        viewModelScope.launch {
            val response = SkGqlClient.skMutation(
                CheckEmailMutation(email = email),
                showDefaultLoading = true
            )
            if (response?.data != null) {
                checkResultLiveData.postValue(response.data!!.checkEmail)
            }
        }
    }
}